/**
 * 风险评估字典条目规则表管理初始化
 */
var QcCaseDetail = {
	id: "qcCaseDetailTable",	//表格id
	seItem: null,		//选中的条目
	table: null,
	layerIndex: -1,
	depType:"科室",
};
QcCaseDetail.drawTable = function(tableData){
    this.$table =
        $('#qcCaseDetailTable').bootstrapTable({
            data:tableData,
            striped: false,//是否显示行间隔色
            pagination: true,//是否显示分页
            showFooter: false,
            //paginationLoop: false,
            pageSize : 10,//用于设置每页初始显示的条数
            //pageList :[4],
            sidePagination: 'server',//设置在哪进行分页，默认”client”，可选”server”,返回数据模板不同
            sortOrder: 'desc',// desc  asc
            maintainSelected: true,//设为true 为选中的状态
            cache: false,
            search:false, //搜索框
            columns: [
                {title: '患者姓名', field: 'name', align: 'center', width:50,valign: 'middle',sortable: false},
                {title: '病案号', field: 'mrNum', align: 'center', width:40,valign: 'middle',sortable: false},
                {title: '就诊科室', field: 'admLocDesc', align: 'center', width:50, valign: 'middle',sortable: false},
                {title: '入院日期', field: 'admDate', align: 'center', width:70, valign: 'middle',sortable: false},
                {title: '主治医生', field: 'admDoctorName', align: 'center', width:80,valign: 'middle',sortable: false},
                {title: '入组病种', field: 'btDesc', align: 'center', width:100,valign: 'middle',sortable: false},
                {title: '触发质控项', field: 'qcNum', align: 'center', width:70, valign: 'middle',sortable: false,
                    formatter:function(value,row,index){
                        if(row.qcNum >0){
                            return "<a title='详细' onclick='openQcDetail(&apos;"+row.id+"&apos;,&apos;"+row.name+"&apos;,&apos;"+row.mrNum+"&apos;)'>"+value+"</a>";
                        }else{
                            return 0;
                        }

                    }}
            ],
            onPostHeader: function(){  //当<thead></thead>中的内容被加载完后或者在你所用的DOM中有定义则被触发
                //$(".th-inner").css("font-weight","700");//表头字体加粗
                $("#qcCaseDetailTable > tbody td").each(function(index){//鼠标悬浮 显示表格数据
                    $(this).attr("title",$(this).text());
                });
            }
        });
};
/**
 * 初始化表格的列
 */
QcCaseDetail.initColumn = function () {
	return [
        {title: '患者姓名', field: 'name', align: 'center', width:50,valign: 'middle',sortable: false},
        {title: '病案号', field: 'mrNum', align: 'center', width:40,valign: 'middle',sortable: false},
        {title: '就诊科室', field: 'admLocDesc', align: 'center', width:50, valign: 'middle',sortable: false},
        {title: '入院日期', field: 'admDate', align: 'center', width:70, valign: 'middle',sortable: false},
        {title: '主治医生', field: 'admDoctorName', align: 'center', width:80,valign: 'middle',sortable: false},
        {title: '入组病种', field: 'btDesc', align: 'center', width:100,valign: 'middle',sortable: false},
        {title: '触发质控项', field: 'qcNum', align: 'center', width:70, valign: 'middle',sortable: false,
            formatter:function(value,row,index){
                if(row.qcNum >0){
                    return "<a title='详细' onclick='openQcDetail(&apos;"+row.id+"&apos;,&apos;"+row.name+"&apos;,&apos;"+row.mrNum+"&apos;)'>"+value+"</a>";
                }else{
                    return 0;
                }

            }}
    ];
};


/**
 * 查询病例
 */
QcCaseDetail.search =function(){
    var params = {};
    params.key = $('#key').val();
    params.office = $("#office").val();
    params.depart = $("#depart").val();
    params.drgType = $("#drgType").val();
    params.doctor = $("#doctor").val();
    params.medicalGroup = $("#medicalGroup").val();

    QcCaseDetail.table.refresh({query: params,pageNumber: 1});
}
function openQcDetail(episodeId,name,mrNum){
    var index = layer.open({
        type: 2,
        title: ['&nbsp;触发质控项-'+name+'-'+mrNum,'padding-left:20px'],
        area: ['900px', '397px'], //宽高
        fix: false, //不固定
        skin:'rbLBStyle  layer-ext-hisui',  //LB为layerBorder缩写
        //maxmin: true,
        content: Sys.backendPath + '/analysis/qcportal/to_qcDetail?episodeId='+episodeId
    });
}
$(function () {
    var params = {};
    params.key = $('#key').val();
    params.office = $("#office").val();
    params.depart = $("#depart").val();
    params.drgType = $("#drgType").val();
    params.doctor = $("#doctor").val();
    params.medicalGroup = $("#medicalGroup").val();

    var table = new BSTable(QcCaseDetail.id, "/sdc/home/qcCaseList", QcCaseDetail.initColumn());
    table.setPaginationType("server");
    table.setQueryParams(params);
    table.setShowColumns(false);
    table.setShowRefresh(false);
    table.setShowToggle(false);
    table.setPageSize(15);
    table.setSubHeight(-30);

    QcCaseDetail.table = table.init();
});

